package com.micaelvesterlund.skeerkie.shared.util;

import java.util.ArrayList;
import java.util.List;

import com.micaelvesterlund.skeerkie.shared.domain.City;
import com.micaelvesterlund.skeerkie.shared.domain.League;
import com.micaelvesterlund.skeerkie.shared.domain.Name;
import com.micaelvesterlund.skeerkie.shared.domain.Player;
import com.micaelvesterlund.skeerkie.shared.domain.Skills;
import com.micaelvesterlund.skeerkie.shared.domain.Team;

public class LeagueGenerator {
	public static final int NR_OF_TEAMS = 16;
	private static final int NR_OF_PLAYERS = 16;

	public League createLeague() {
		NameGenerator nameGenerator = new NameGenerator();
		SkillsGenerator skillsGenerator = new SkillsGenerator();
		List<Team> teams = new ArrayList<Team>();
		List<Name> cityNames = new ArrayList<Name>();
		for (int i = 0; i < NR_OF_TEAMS; i++) {
			Name cityName = nameGenerator.createCityName();
			while (cityNames.contains(cityName)) {
				cityName = nameGenerator.createCityName();
			}
			cityNames.add(cityName);
			City city = new City(cityName);
			Name name = new Name("Hockey Club");
			List<Player> players = new ArrayList<Player>();
			for (int j = 0; j < NR_OF_PLAYERS; j++) {
				Name firstName = nameGenerator.createFirstName();
				Name lastName = nameGenerator.createLastName();
				Skills skills = skillsGenerator.createSkills();
				Player player = new Player(firstName, lastName, skills);
				players.add(player);
			}
			Team team = new Team(city, name, players);
			teams.add(team);
		}
		return new League(teams);
	}
}
